<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TeachingCourseware extends Model
{
    protected $table = 'teaching_courseware';

    public static function options($id)
    {
        if (! $self = static::find($id)) {
            return [];
        }

        return $self->brothers()->pluck('name', 'id');
    }

    public function children()
    {
        return $this->hasMany(TeachingCourseware::class, 'teaching_type');
    }

    public function brothers()
    {
        return $this->parent->children();
    }
}
